#ifndef _BUCKET_H_
#define _BUCKET_H_

#include <list>
#include <utility>
#include <boost/thread/shared_mutex.hpp>

template<typename Key, typename Value>
class bucket {
	private:
		typedef std::pair<Key, Value> bucket_value;
		typedef std::list<bucket_value> bucket_data;
		typedef typename std::list<bucket_value>::iterator bucket_iterator;
	
	public:
		Value value_for(const Key& key, const Value& defaultValue) const;
		void add_or_update_mapping(const Key& key, const Value& value);
		void remove(const Key& key);
		bucket_data getData() const;
		
	private:		
		bucket_iterator find_entry_for(const Key& key);
		
		bucket_data data;
		mutable boost::shared_mutex mutex;
};

#include "bucket.tcc"

#endif
